package com.media.publish.adapter;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;


import java.util.ArrayList;
import java.util.List;

import com.media.publish.DynamicSearchTopicFragment;
import com.media.publish.bean.DoyTypeData;

//发布动态-选择话题
public class DynamicSearchTopicTabAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragments = new ArrayList<>();

    public DynamicSearchTopicTabAdapter(FragmentManager fm) {
        super(fm);
    }

    /**
     * 话题
     *
     */
    public void setData(List<DoyTypeData.DataBean> tabName) {
        fragments.clear();
        for (DoyTypeData.DataBean recommendTags : tabName) {
            fragments.add(new DynamicSearchTopicFragment(recommendTags));
        }
        notifyDataSetChanged();
    }

    /**
     * 讲坛
     *
     * @param fragments
     */
    public void setEmptyTitleFragment(ArrayList<Fragment> fragments) {
        this.fragments = fragments;
        notifyDataSetChanged();
    }


    @Override
    public Fragment getItem(int i) {
        return fragments.get(i);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return "";
    }
}